﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views.mainmenu {
    import flash.events.*;
    import org.robotlegs.core.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.*;
    import net.wooga.pets.views.components.mainmenu.*;
    import net.wooga.pets.constants.*;
    import org.robotlegs.mvcs.*;

    public class VisitFriendsPanelMediator extends Mediator implements IMediator {

		[Inject]
        public var visitFriendsPanel:VisitFriendsPanel;
		[Inject]
        public var friendsModel:FriendsModel;
		[Inject]
        public var userModel:UserModel;
		[Inject]
        public var gameStateModel:GameStateModel;
		[Inject]
        public var languageModel:LanguageModel;

        override public function onRegister():void{
            eventMap.mapListener(this.visitFriendsPanel, ViewCompEvent.CLICK, this.returnHome);
            eventMap.mapListener(eventDispatcher, EventConstants.SHOW_VISIT_FRIENDS_PANEL, this.showVisitFriendsPanel);
            eventMap.mapListener(eventDispatcher, EventConstants.HIDE_VISIT_FRIENDS_PANEL, this.hideVisitFriendsPanel);
        }
        private function showVisitFriendsPanel(_arg1:Event):void{
            var _local2:String = this.userModel.visitingFriendID;
            var _local3:Object = this.friendsModel.getVisitingFriendObject(_local2);
            var _local4:String = this.languageModel.getTextByKey("visitfriend_display_name", {friends_name:_local3.first_name});
            this.visitFriendsPanel.setLabels(_local3.level, _local3.xp, _local4, this.languageModel.getTextByKey("visitfriend_display_gohome"));
            this.visitFriendsPanel.show();
        }
        private function hideVisitFriendsPanel(_arg1:Event):void{
            this.visitFriendsPanel.hide();
        }
        private function returnHome(_arg1:ViewCompEvent):void{
            this.userModel.visitingFriendID = null;
            dispatch(new InfoEvent(EventConstants.VISIT_FRIEND, this.userModel.mySocialID));
            dispatch(new Event(EventConstants.GO_HOME_BUTTON_CLICKED));
            dispatch(new InfoEvent(EventConstants.SELECT_MENU_TAB, GameConstants.MENU_TAB_FRIENDS));
        }

    }
}//package net.wooga.pets.views.mainmenu 
